#include <iostream>
#include <atomic>

#include "SharedBuf.hpp"




struct AAA {
    char buffer1[SIZE * 1024 * 1024];
    int Id;
    char buffer2[SIZE * 1024 * 1024];
};


int main() {
    SharedServer<struct AAA> sbq(ShmService::SHM_CONNECT, CAPACITY, BUFCAPACITY);
    sbq.InitServer();

    shared_buf_t<struct AAA> objbuf(sbq);

    srand((unsigned)time(NULL));


    for (int i = 0; i < COUNT; i++) {
        std::cout << "push ID:" << i << std::endl;
        objbuf._data->Id = i;
        std::atomic<size_t> time = 0;
        size_t start = clock();


        objbuf.Push();


        size_t end = clock();
        time += (end - start);
        printf("push_back耗时: %lu μs\n\n", time.load());
    }
    getchar();

    return 0;
}